package com.bwie.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfig {
    public static final String DIRECT_QUEUE_ONE="direct_queue_one";
    public static final String DIRECT_EXCHANGE_ONE="direct_queue_one";
    public static final String DIRECT_ROUTKING_ONE="direct_queue_one";

    @Bean
    public Queue directQueue(){
        return new Queue(DIRECT_QUEUE_ONE);
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(DIRECT_EXCHANGE_ONE);
    }

    @Bean
    public Binding binding(){
        return BindingBuilder.bind(directQueue()).
                to(directExchange()).with(DIRECT_ROUTKING_ONE);
    }

    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
